
PLATFORM := $(shell uname)

# If you're not using Cygwin or Linux, 
# you will need to add your own setup here
ifneq (, $(findstring CYGWIN, $(PLATFORM)))
    GL_LIBS = -lopengl32 -lglu32 -lglut32
endif

ifneq (, $(findstring Linux, $(PLATFORM)))
    GL_LIBS = -lGL -lGLU -lglut
endif

CC = g++ -Wall 
OBJS =  GLee.o objLoader.o obj_parser.o list.o ModelViewer.o shader.o matrix4f.o matrix3f.o GLError.o Light.o Ground.o Skybox.o Vehicle.o HemisphericLight.o
TARGET = objtest
RUNTARGET = world

.PHONY: all clean

test: $(RUNTARGET)

$(RUNTARGET): world.o $(OBJS)
	$(CC) -o $(RUNTARGET) world.o $(OBJS) $(GL_LIBS)
	
world.o: world.cpp ModelViewer.hpp
	$(CC) -c world.cpp
	

all: $(TARGET)

$(TARGET): objTester.o $(OBJS)
	$(CC) -o $(TARGET) objTester.o $(OBJS) $(GL_LIBS)

objTester.o: objTester.cpp objLoader.h
	$(CC) -c objTester.cpp

objLoader.o: objLoader.cpp objLoader.h obj_parser.h
	$(CC) -c objLoader.cpp

obj_parser.o: obj_parser.cpp obj_parser.h list.h
	$(CC) -c obj_parser.cpp

list.o: list.h list.cpp
	$(CC) -c list.cpp
	
ModelViewer.o: ModelViewer.cpp ModelViewer.hpp
	$(CC) -c ModelViewer.cpp
	
GLee.o : GLee.c GLee.h
	gcc -c  GLee.c
	
shader.o : shader.cpp shader.h
	$(CC)  -c shader.cpp
	
matrix3f.o: matrix3f.cpp matrix3f.h
	$(CC)  -c matrix3f.cpp
	
matrix4f.o: matrix4f.cpp matrix4f.h
	$(CC)  -c matrix4f.cpp

GLError.o: GLError.cpp GLError.h
	$(CC) -c GLError.cpp
	
	
Light.o: Light.cpp Light.hpp
	$(CC) -c Light.cpp
	
Ground.o: Ground.cpp Ground.h
	$(CC) -c Ground.cpp

Skybox.o: Skybox.cpp Skybox.h
	$(CC) -c Skybox.cpp
	
Vehicle.o: Vehicle.cpp Vehicle.h
	$(CC) -c Vehicle.cpp

HemisphericLight.o: HemisphericLight.cpp HemisphericLight.h
	$(CC) -c HemisphericLight.cpp

clean:
	rm -f *.o $(TARGET) $(RUNTARGET)
